package se.lnu.axez.shaders;

import java.io.IOException;

import se.lnu.axez.ResourceUtility;
import android.content.res.Resources;

/**
 * Vertex shader loaded from raw package resource.
 * 
 * @author stan
 * 
 */
public abstract class ResourceVertexShader extends VertexShader {
	private final Resources resources;
	
	public ResourceVertexShader(Resources resources) {
		if (resources == null) {
			throw new IllegalArgumentException("resources cannot be null");
		}
		
		this.resources = resources;
	}
	
	@Override
	protected String getShaderCode() {
		try {
			return ResourceUtility.readStringResource(this.resources, this.getResourceID());
		} catch (IOException e) {
			// TODO: reconsider this
			e.printStackTrace();
		}
		
		return null;
	}
	
	protected abstract int getResourceID();
}
